<template>
  <div>
    <NarBar>
      <div slot='left'>
        <img src="~assets/img/tabbar/left.png" alt="" class="back" @click="backClick">
      </div>
      <div slot='center' class="title">
        <div v-for="(item,index) in title" class="titleItem" :class="{active: index === currentIndex}" @click="titleClick(index)">
            {{item}}
        </div>
      </div>
    </NarBar>
  </div>
</template>

<script>
  import NarBar from 'components/common/navbar/NavBar.vue'


  export default {
    name: 'DetailNavBar',
    components: {
      NarBar
    },
    data(){
      return{
        title:['商品','参数','评论','推荐'],
        currentIndex:0
      }
    },
    methods:{
      titleClick(index){
        this.currentIndex = index
        this.$emit('titleClick',index)
      },
      backClick(){
        this.$router.go(-1)
      }
    }
  }
</script>

<style scoped>

  .title{
    display: flex;
  }

  .titleItem{
    flex: 1;
    font-size: 0.8125rem;
  }

  .active{
    color: hotpink;
  }

  .back{
    margin-top: 0.9375rem;
    width: 1.25rem;
    height: 1.25rem;
  }
</style>
